/*
 * Copyright (c) 2002-2012 Alibaba Group Holding Limited.
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hd.assistant.web.home.module.screen.detail;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.BindException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.citrus.turbine.Context;
import com.alibaba.citrus.turbine.dataresolver.Param;
import com.hd.assistant.web.common.base.BasePageAnalysis;

/**
 * 外部重定向，用来示范redirect token的使用方法。
 * 
 * @author Michael Zhou
 */
public class TbSearchPageAnalysis extends BasePageAnalysis {
	private final static Logger log = LoggerFactory
			.getLogger(TbSearchPageAnalysis.class);

	public void execute(@Param("pindex") String pindex,
			@Param("index") String index, @Param("url") String url,
			Context context) {
		try {
			if(url == null){
				log.error("TbSearchPageAnalysis no url ");
				return;
			}
			context.put("pindex", pindex == null ? 3 : pindex);
			context.put("index", index == null ? 300 : index);
		    String content = getContent(URLDecoder.decode(url, "utf-8"),"gbk");
		    context.put("content", content);
		} catch (Exception e) {
			log.error("error:", e);
		}

	}

	
}
